<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<body>
<!--头部-->
<div th:fragment="header">
    <div class="fly-header layui-bg-black">
        <div class="layui-container">
            <a class="fly-logo" href="/">
                <img src="/images/logo.png" alt="layui">
            </a>
            <ul class="layui-nav fly-nav layui-hide-xs">
                <li class="layui-nav-item layui-this">
                    <a href="/"><i class="iconfont icon-jiaoliu"></i>交流</a>
                </li>
                <li class="layui-nav-item">
                    <a target="_blank"
                       href="http://mp.weixin.qq.com/profile?src=3&timestamp=1540977861&ver=1&signature=3qeqO*kmTtJFJWWbPXYE-fFExWqw57D1R0JOxhYwfWoTw6-MHGf1E5tos8VrZBBY786QL7JFWDZIIDxsTMdRKA==">
                        <i class="iconfont icon-iconmingxinganli"></i>公众号
                    </a>
                </li>
            </ul>

            <shiro:guest>
                <ul class="layui-nav fly-nav-user">

                    <!-- 未登入的状态 -->
                    <li class="layui-nav-item">
                        <a class="iconfont icon-touxiang layui-hide-xs" href="/login"></a>
                    </li>
                    <li class="layui-nav-item">
                        <a href="/login">登入</a>
                    </li>
                    <li class="layui-nav-item">
                        <a href="/register">注册</a>
                    </li>
                    <li class="layui-nav-item layui-hide-xs">
                        <a href="/app/qq/" onclick="layer.msg('正在通过QQ登入', {icon:16, shade: 0.1, time:0})" title="QQ登入"
                           class="iconfont icon-qq"></a>
                    </li>
                    <li class="layui-nav-item layui-hide-xs">
                        <a href="/app/weibo/" onclick="layer.msg('正在通过微博登入', {icon:16, shade: 0.1, time:0})"
                           title="微博登入" class="iconfont icon-weibo"></a>
                    </li>
                </ul>
            </shiro:guest>

            <shiro:user>
                <ul class="layui-nav fly-nav-user">
                    <!-- 登入后的状态 -->
                    <li class="layui-nav-item">
                        <a class="fly-nav-avatar" th:href="@{'/user/center'}">
                            <cite class="layui-hide-xs">
                                <shiro:principal property="username"/>
                            </cite>
                            <i class="iconfont icon-renzheng layui-hide-xs" title="认证信息：layui 作者"></i>
                            <i class="layui-badge fly-badge-vip layui-hide-xs">VIP3</i>
                            <!-- todo 暂时注释 -->
                            <!--<img th:src="${session.profile.avatar}">-->
                        </a>
                        <dl class="layui-nav-child">
                            <dd><a href="/user/setting"><i class="layui-icon">&#xe620;</i>基本设置</a></dd>
                            <dd><a href="/user/message"><i class="iconfont icon-tongzhi" style="top: 4px;"></i>我的消息</a>
                            </dd>
                            <dd>
                                <!-- todo 暂时注释 -->
                                <!--<a th:href="@{'/u/' + ${session.profile.id}}">
                                    <i class="layui-icon" style="margin-left: 2px; font-size: 22px;">&#xe68e;</i>我的主页
                                </a>-->
                            </dd>
                            <hr style="margin: 5px 0;">
                            <dd><a href="/user/logout" style="text-align: center;">退出</a></dd>
                        </dl>
                    </li>
                </ul>
            </shiro:user>
        </div>
    </div>
</div>
<!--头部结束-->

<!--头部nav-->
<div th:fragment="header-nav">
    <div class="fly-panel fly-column">
        <div class="layui-container">
            <ul class="layui-clear">
                <li th:classappend="${currentCategoryId} == null ? 'layui-hide-xs layui-this' : ''"><a href="/">首页</a>
                </li>
                <li th:each="category: ${application.categorys}"
                    th:classappend="${category.id} eq ${currentCategoryId} ? 'layui-hide-xs layui-this' : ''">
                    <a th:href="'/category/' + ${category.id}" th:text="${category.name}"></a>
                </li>
                <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><span class="fly-mid"></span></li>

                <!-- 用户登入后显示 -->
                <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a
                        href="/user/center#index">我发表的贴</a></li>
                <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a
                        href="/user/collection#collection">我收藏的贴</a></li>
            </ul>

            <div class="fly-column-right layui-hide-xs">
                <span class="fly-search"><i class="layui-icon"></i></span>
                <a href="/user/post" class="layui-btn">发表新帖</a>
            </div>
            <div class="layui-hide-sm layui-show-xs-block"
                 style="margin-top: -10px; padding-bottom: 10px; text-align: center;">
                <a href="/user/post" class="layui-btn">发表新帖</a>
            </div>
        </div>
    </div>
</div>
<!--头部nav结束-->

<!--底部-->
<div th:fragment="footer">
    <div class="fly-footer">
        <p><a href="http://fly.layui.com/" target="_blank">Fly社区</a> 2017 &copy; <a href="http://www.layui.com/"
                                                                                    target="_blank">layui.com 出品</a></p>
        <p>
            <a href="http://fly.layui.com/jie/3147/" target="_blank">付费计划</a>
            <a href="http://www.layui.com/template/fly/" target="_blank">获取Fly社区模版</a>
            <a href="http://fly.layui.com/jie/2461/" target="_blank">微信公众号</a>
        </p>
    </div>
</div>
<!--底部结束-->

<!--本周热议-->
<div th:fragment="weekPopular">
    <dl class="fly-panel fly-list-one" id="post-hots">
        <dt class="fly-panel-title">本周热议</dt>
        <script id="hotsDd" type="text/html">
            {{#  layui.each(d.list, function(index, item){ }}
            <dd>
                <a href="/post/{{item.id}}">{{ item.title }}</a>
                <span><i class="iconfont icon-pinglun1"></i> {{ item.comment_count }}</span>
            </dd>
            {{#  }); }}
            {{#  if(d.list.length === 0){ }}
            <div class="fly-none">没有相关数据</div>
            {{#  } }}
        </script>
    </dl>
    <script>
        layui.use(['laytpl', 'fly'], function () {
            var laytpl = layui.laytpl;

            var post_hots = document.getElementById("post-hots");
            var tpl = document.getElementById("hotsDd").innerHTML;
            var data = {};
            $.ajax({
                url: '/post/hots',
                async: false,
                success: function (res) {
                    if (res.code == 0) {
                        data.list = res.data;
                    }
                }
            });
            laytpl(tpl).render(data, function (html) {
                post_hots.innerHTML += html;
            });
        });
    </script>
</div>
<!--本周热议结束-->

<!--签到-->
<div th:fragment="signin">
    <div class="fly-panel fly-signin">
        <div class="fly-panel-title">
            签到
            <i class="fly-mid"></i>
            <a href="javascript:;" class="fly-link" id="LAY_signinHelp">说明</a>
            <i class="fly-mid"></i>
            <a href="javascript:;" class="fly-link" id="LAY_signinTop">活跃榜<span class="layui-badge-dot"></span></a>
            <span class="fly-signin-days">已连续签到<cite>16</cite>天</span>
        </div>
        <div class="fly-panel-main fly-signin-main">
            <button class="layui-btn layui-btn-danger" id="LAY_signin">今日签到</button>
            <span>可获得<cite>5</cite>飞吻</span>

            <!-- 已签到状态 -->
            <!--
            <button class="layui-btn layui-btn-disabled">今日已签到</button>
            <span>获得了<cite>20</cite>飞吻</span>
            -->
        </div>
    </div>
</div>
<!--签到结束-->

<!--广告与友情链接-->
<div th:fragment="ads">
    <div class="fly-panel">
        <div class="fly-panel-title">
            这里可作为广告区域
        </div>
        <div class="fly-panel-main">
            <a href="http://layim.layui.com/?from=fly" target="_blank" class="fly-zanzhu"
               time-limit="2017.09.25-2099.01.01" style="background-color: #5FB878;">LayIM 3.0 - layui 旗舰之作</a>
        </div>
    </div>

    <div class="fly-panel fly-link">
        <h3 class="fly-panel-title">友情链接</h3>
        <dl class="fly-panel-main">
            <dd><a href="http://www.layui.com/" target="_blank">layui</a>
            <dd>
            <dd><a href="http://layim.layui.com/" target="_blank">WebIM</a>
            <dd>
            <dd><a href="http://layer.layui.com/" target="_blank">layer</a>
            <dd>
            <dd><a href="http://www.layui.com/laydate/" target="_blank">layDate</a>
            <dd>
            <dd>
                <a href="mailto:xianxin@layui-inc.com?subject=%E7%94%B3%E8%AF%B7Fly%E7%A4%BE%E5%8C%BA%E5%8F%8B%E9%93%BE"
                   class="fly-link">申请友链</a>
            <dd>
        </dl>
    </div>
</div>
<!--广告结束-->

</body>
</html>